﻿using AMatysiak.Methods;

namespace AMatysiak.Collections
{
    public class Pair<K, V>
    {
        protected K key;
        protected V value;

        public Pair(K key, V value)
        {
            this.key = key;
            this.value = value;
        }

        public K Key
        {
            get { return this.key; }
            set { this.key = value; }
        }

        public V Value
        {
            get { return this.value; }
            set { this.value = value; }
        }

        public override int GetHashCode()
        {
            return Key.GetHashCode() * Value.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            if (obj is Pair<K, V>)
                return GetHashCode() == obj.GetHashCode();

            return base.Equals(obj);
        }

        public override string ToString()
        {
            return "Pair [ Key = {0}, Value = {1} ]".FormatWith(Key, Value);
        }
    }
}
